#include<bits/stdc++.h>
using namespace std;
const int M=1e5+7;
int t;
int n,m,l,v;
int p[M];
int b[M];
struct ffff{
    int di,vi,ai;
    bool f;
}car[M];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for(int fa=1;fa<=t;fa++)
    {
        memset(b,0,sizeof(b));
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++)
        {
            cin>>car[i].di>>car[i].vi>>car[i].ai;
            car[i].f=false;
            b[car[i].di]=i;
        }
        int maxn=0;
        int minn=INT_MAX;
        for(int i=1;i<=m;i++)
        {
            cin>>p[i];
            b[p[i]]=-1;
            maxn=max(maxn,p[i]);
            minn=min(minn,p[i]);
        }
        for(int i=1;i<=n;i++)
        {
            if(car[i].di<maxn&&car[i].vi>v)
            {
                car[i].f=true;
            }
        }
        int cnt=0;
        for(int i=1;i<=n;i++)
        {
            if(car[i].f)
            {
                cnt++;
            }
        }
        cout<<cnt<<" ";
        if(cnt!=0)
        {
            cout<<m-1;

        }
        else{
            cout<<m;
        }

    }
    return 0;
}
